//
//  HEAfterRefundPriceCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/13.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEAfterRefundPriceCell.h"

@interface HEAfterRefundPriceCell ()<UITextFieldDelegate>

@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *priceLb;
@property (nonatomic, strong) UITextField *numTf;

@end

@implementation HEAfterRefundPriceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    // 商品名称
    _titleLb = [UILabel new];
    _titleLb.text = @"退款金额";
    _titleLb.font = DYFont(16);
    [self.contentView addSubview:_titleLb];
    
    // 价格
    _priceLb = [UILabel new];
    _priceLb.text = @"￥";
    _priceLb.font = DYBlodFont(16);
    _priceLb.textAlignment = NSTextAlignmentRight;
    _priceLb.textColor = KHexColor(@"#FF5757");
    [self.contentView addSubview:_priceLb];
    
    
    _numTf = [UITextField new];
    _numTf.font = DYBlodFont(18);
    _numTf.textColor = CPriceColor;
    _numTf.textAlignment = NSTextAlignmentCenter;
    _numTf.keyboardType = UIKeyboardTypeNumberPad;
    _numTf.delegate = self;
    _numTf.text = @"0";
    [self.contentView addSubview:_numTf];

    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_numTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.width.mas_offset(65);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(_numTf.mas_left).mas_offset(-5);
        make.width.mas_equalTo(40);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
    _numTf.text = formModel.as_returnAmount;
}

#pragma mark - TextFiledDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    return NO;
}

//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//
//    NSString *text = [textField.text stringByReplacingCharactersInRange:range withString:string];
//
//    self.formModel.as_returnAmount = text;
//    return YES;
//}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
